<?php

class omekpi_mdl_packager_log extends dbeav_model{
    
    function getPageData($where=''){
        return $this->db->select('SELECT sdb_omekpi_packager_log.* , sdb_omekpi_employee.* ' .
                'FROM `sdb_omekpi_packager_log` INNER JOIN sdb_omekpi_employee ' .
                'ON sdb_omekpi_packager_log.employee_id = sdb_omekpi_employee.employee_id and employee_type='."'".'packager'."' ".$where);
    }
    
    function getCount($where=''){
        $array=array();
        $count = $this->db->select('select package_numbers,packaged_numbers from sdb_omekpi_packager_log '.$where.' limit 1');
        if($count){ 
            foreach($count as $key=>$value){
                $array =  $value;
            }
        }
        $sum = $this->db->select( 'select sum(my_packaged_numbers) as count_my_packaged_numbers from sdb_omekpi_packager_log '.$where);
        foreach($sum as $k=>$v){
            return array_merge($array,$v);
        }
    }

    function search($where){
        return $this->db->select("SELECT * FROM sdb_omekpi_packager_log ".$where);
    }
    
    function getContentPackageedCount(){
        $count = $this->db->select('select packaged_numbers from sdb_omekpi_packager_log limit 1');
        foreach($count as $v){
            return $v['packaged_numbers'];
        }
    }
    
    function update_mypackaged($array){
        $this->db->exec("update sdb_omekpi_packager_log set my_packaged_numbers='".$array['my_packaged_numbers'].
        "' where employee_id='".$array['employee_id']."' and createdate='".$array['createdate']."'");
    }
    
    function update_packaged($allcount){
        $this->db->exec('update sdb_omekpi_packager_log set packaged_numbers='.$allcount);
    }
    
    function updateCount($count,$allcount){
        $this->db->exec('update sdb_omekpi_packager_log set package_numbers='.$count.',packaged_numbers='.$allcount);
    }
}
?>